const { Sequelize, Op, DataTypes } = require('sequelize');
const sequelize = new Sequelize('text', 'postgres', 'zyfyyds', {
    host: 'zyfyyds.top',
    dialect: 'postgres'
})

let modelobj = {}

modelobj['Produces'] = sequelize.define('produces', {//统一s结尾
        name: {
            type: DataTypes.STRING,
            allowNull: false
        },
        price: {
            type: DataTypes.DECIMAL,
            allowNull: false
        },
        stock: {
            type: DataTypes.INTEGER,
            allowNull: false
        }
    })

modelobj.sync = async () => {
    await  sequelize.sync({force:true})
    modelobj.Produces.bulkCreate([
        {
            name:'Soul',
            price:'112',
            stock:1
        },
        {
            name:'S',
            price:'11.11',
            stock:1
        },
        {
            name:'S',
            price:'2',
            stock:8
        }
    ]);
}
modelobj.Op = Op;
module.exports = modelobj;
